import { IUI, Text } from 'leafer-ui'

export type IUIItem = IUI | Text

export const getHasNameObjects = (uiItem: IUI) => {
    if (!uiItem.children) {
        return {}
    }
    const hasNames = uiItem.find((item: IUI) =>
        item.name && item.name !== '' ? 1 : 0
    )
    const result: {
        [key: string]: IUIItem
    } = {}
    hasNames.forEach((item: IUI) => {
        result[item.name!] = item
    })
    return result
}
